﻿<Window x:Class="Graphing.View.GraphView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:Graph="clr-namespace:Graphing"
             xmlns:ViewModel="clr-namespace:Graphing.ViewModel"
             mc:Ignorable="d" 
             MaxHeight="500" MaxWidth="500" ResizeMode="NoResize" >

    <Window.Resources>
        <Graph:MultiplyConverter x:Key="multiplyConverter" />
        <ViewModel:PointsViewModel x:Key="PointsViewModel" />
    </Window.Resources>
    
    <Grid Name="grid" DataContext="{StaticResource PointsViewModel}">
        <Canvas Name="canvas" VerticalAlignment="Center" HorizontalAlignment="Center">
            <Canvas.RenderTransform>
                <TransformGroup>
                    <TranslateTransform x:Name="translate" >
                        <TranslateTransform.X>
                            <Binding ElementName="canvas" Path="ActualWidth" Converter="{StaticResource multiplyConverter}" ConverterParameter="0.5" />
                        </TranslateTransform.X>

                        <TranslateTransform.Y>
                            <Binding ElementName="canvas" Path="ActualHeight" Converter="{StaticResource multiplyConverter}" ConverterParameter="0.5" />
                        </TranslateTransform.Y>
                    </TranslateTransform>
                    <ScaleTransform ScaleX="1" ScaleY="-1" CenterX="{Binding ElementName=translate, Path=X}" CenterY="{Binding ElementName=translate, Path=Y}" />
                </TransformGroup>
            </Canvas.RenderTransform>
        </Canvas>
    </Grid>
</Window>
